home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Demo's / Igor Demo Pro / 1 PutContentsIn Igor Pro Folder / WaveMetrics Procedures / Data Manipulation / MatrixToMatrix < prev    next >
Text File  |  1996-01-29  |  1KB  |  41 lines

  1. | MatrixToMatrix
  2. | interpolates or decimates a 2D matrix
  3. #pragma rtGlobals=1        // Use modern global access method.
  4.  
  5. Macro MatrixToMatrix(inMatrix,outMatrix,factor,mktbl,mkimg)
  6.     String inMatrix,outMatrix="matrix"
  7.     Variable factor=2    // double each dimension, 4 times as many points
  8.     Variable mktbl=2,mkimg=2
  9.     Prompt inMatrix,"Input 2D matrix",popup,WaveList("*",";","")
  10.     Prompt outMatrix,"Output matrix name"
  11.     Prompt factor "Interpolation factor (2 doubles rows and columns, 0.5 halves them)"
  12.     Prompt mktbl,"Put output matrix in new table?",popup,"Yes;No"
  13.     Prompt mkimg,"Display output matrix as image?",popup,"Yes;No"
  14.  
  15.     Silent 1;PauseUpdate
  16.     if( WaveDims($inMatrix) != 2 )
  17.         Abort inMatrix+" is not a two-dimensional wave."
  18.     endif
  19.     Variable rows= DimSize($inMatrix,0)
  20.     Variable cols= DimSize($inMatrix,1)
  21.     Duplicate/O $inMatrix,$outMatrix
  22.     Redimension/N=(rows*factor,cols*factor) $outMatrix
  23.     CopyScales/I $inMatrix, $outMatrix
  24.     // Make a temporary contour plot
  25.     // so we can use ContourZ to interpolate from X,Y,Z into MatrixXY
  26.     Display/W=(0,30,200,80)    // teeny window
  27.     DoWindow/C WM_MatrixtoMatrix
  28.     AppendMatrixContour $inMatrix;ModifyContour $inMatrix autoLevels={*,*,0},update=1,labels=0
  29.     ModifyGraph axThick=0,nolabel=2;Textbox/A=LC/F=0 "Computing "+outMatrix;DoUpdate
  30.     $outMatrix= ContourZ("","",0,x,y)
  31.     DoWindow/K WM_MatrixtoMatrix
  32.     Preferences 1
  33.     if( mktbl == 1)
  34.         Edit $outMatrix
  35.     endif
  36.     if( mkimg == 1)
  37.         Display;AppendImage $outMatrix
  38.     endif
  39. EndMacro
  40.  
  41.